/*
 *  NFCSigning - Open source library for signing/validation of NDEF messages
 *  Copyright (C) 2009-2010 The NFCSigning Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 *
 */
package sampleappa;

import com.ericsson.nfc.signing.algorithm.PrivateKey;
import com.ericsson.nfc.signing.certificate.X509Certificate;
import com.ericsson.nfc.signing.record.CertificateBytes;
import com.ericsson.nfc.signing.record.URIRecord;
import java.io.IOException;

/**
 *
 * @author emarkki
 */
public class Cert {
    
    private String title;
    private URIRecord builtInUri;
    private PrivateKey privateKey;
    private X509Certificate[] chain;
    private CertificateBytes[] chainBytes;
    private int keyAlgorithm;
    public static final int KEY_RSA = 0;
    public static final int KEY_DSA = 1;
    public static final int KEY_ECDSA = 2;

    public Cert(String title, URIRecord builtInUri, PrivateKey privateKey, int keyAlgorithm, X509Certificate[] chain) throws IOException {
        this.title = title;
        this.builtInUri = builtInUri;
        this.privateKey = privateKey;
        this.keyAlgorithm = keyAlgorithm;
        this.chain = chain;
        this.chainBytes = new CertificateBytes[chain.length];
        for(int i = 0; i < chainBytes.length; i++) {
            chainBytes[i] = new CertificateBytes(chain[i].getBytes());
        }
    }

    public String getTitle() {
        return title;
    }

    public URIRecord getBuiltInUri() {
        return builtInUri;
    }

    public PrivateKey getPrivateKey() {
        return privateKey;
    }

    public int getKeyAlgorithm() {
        return keyAlgorithm;
    }
    
    public X509Certificate[] getChain() {
        return chain;
    }

    public CertificateBytes[] getChainBytes() {
        return chainBytes;
    }
    
}
